<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <img src="事件委托.png" alt="">
    <br>
    <ul>
        <li>123451</li>
        <li>123452</li>
        <li>123453</li>
        <li>123454</li>
        <li>123455</li>
    </ul>
    <script>
        // 事件委托的核心原理：给父节点添加监听器，利用事件冒泡影响每一个子节点
        var ul = document.querySelector('ul');
        ul.addEventListener('click', function(e) {
            // alert('123');
            e.target.style.backgroundColor = 'pink';
        });
    </script>
</body>

</html>